<template>
  <el-dialog v-if="visible" :visible="visible" :append-to-body="true" :close-on-click-modal="false" @close="close">
    <div style="width: 100%; display: flex; justify-content: center">
      <el-image v-if="type === 'img'" :src="url" fit="contain" />
      <video v-if="type === 'video'" :src="url" style="width: 100%" :controls="true" />
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: 'MediaShow',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    type: {
      type: String,
      default: 'img'
    },
    url: {
      type: String,
      default: ''
    }
  },
  methods: {
    close() {
      this.$emit('close')
    }
  }
}
</script>
